package excise;

import java.util.ArrayList;
import java.util.List;

/**
 * @author CoderXshuai
 */
public class Main {
    public static void main(String[] args) {
        Integer[] arr = {1, 2, 1, 1, 1, 4, 1, 1};
        System.out.print("您键入的数组为： \n{ ");
        for (int each : arr) {
            System.out.print(each + " ");
        }
        System.out.println("}");
        int indexmax = 0, indexmin = 0, temp;
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > arr[indexmax]) {
                indexmax = i;
            }
            if (arr[i] < arr[indexmin]) {
                indexmin = i;
            }
        }
        temp = arr[0];
        arr[0] = arr[indexmax];
        arr[indexmax] = temp;
        temp = arr[arr.length - 1];
        arr[arr.length - 1] = arr[indexmin];
        arr[indexmin] = temp;
        System.out.println(arr[0]);
        System.out.println(arr[arr.length - 1]);
        List<Integer> list=new ArrayList<>();
        System.out.print("调整后的数组为： \n{ ");
        for (int each : arr) {
            System.out.print(each + " ");
        }
        System.out.println();
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println("}");
    }

}

class MyThread implements Runnable {
    public int count = 5;

    @Override
    public void run() {
        count = 10;
    }
}
